#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<string.h>
int main() {
    int n = 0;
    while (scanf("%d", &n) != EOF)
    {
        for (int i = 0; i < n; i++)
        {
            char arr[101] = { 0 };
            scanf("%s", arr);
            if (arr[0] >= '0' && arr[0] <= '9')
            {
                printf("NO\n");
                continue;
            }
            if (strlen(arr) < 8)
            {
                printf("NO\n");
                continue;
            }
            int fig = 0, cpt = 0, low = 0, other = 0;
            for (int i = 0; i < strlen(arr); i++)
            {
                if (arr[i] >= 'a' && arr[i] <= 'z')
                    low++;
                else if (arr[i] >= 'A' && arr[i] <= 'Z')
                    cpt++;
                else if (arr[i] >= '0' && arr[i] <= '9')
                    fig++;
                else
                    other++;
            }
            if (other != 0)
            {
                printf("NO\n");
                continue;
            }
            if ((low > 0) + (cpt > 0) + (fig > 0) < 2)
            {
                printf("NO\n");
                continue;
            }
            printf("YES\n");
        }
    }
    return 0;
}